<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="global.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目交付物管理</title>
<style type="text/css">
.ctl{
	text-decoration: none;
	color: blue;
	margin: auto 7px;
}
.ctl:HOVER{
	text-decoration: underline;
}
.center{
	text-align: center;
}
</style>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="交付物管理"
			data-options="
				rownumbers:true,
				iconCls: 'icon-edit',
				singleSelect: true,
				toolbar: '#tb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20
			">
		<thead>
			<tr>
				<th data-options="field:'name',width:80,align:'center'">交付物名称</th>
				<th data-options="field:'productName',width:60,align:'center'">所属产品</th>
				<th data-options="field:'projectDeliveryTypeName',width:60,align:'center'">交付物类别</th>
				<th data-options="field:'projectName',width:60,align:'center'">所属项目</th>				
				<th data-options="field:'batchNo',width:70,align:'center'">批次号</th>
				<th data-options="field:'deliveryNumber',width:40,align:'center'">交付数量</th>
				<th data-options="field:'unit',width:30,align:'center'">单位</th>				
				<th data-options="field:'ourHandler',width:60,align:'center'">我方经手人</th>				
				<th data-options="field:'deliveryDate',width:60,align:'center'">交付日期</th>
				<th data-options="field:'id',width:80,align:'center',formatter:formatControl">管理</th>
			</tr>
		</thead>
	</table>

	<div id="tb" style="height:auto">
		<div>
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="clearForm('form', 'addItem')">新增</a>
		</div>
		<div>
			交付物名称: <input class="easyui-textbox" type="text" id="name" style="width:100px;height:25px;">
			所属项目:
			<select data-options="editable: false" id = "project" class="easyui-combobox">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${projects}" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>		
			
			批次号: <input class="easyui-textbox" type="text" id="batchNo" style="width:100px;height:25px;">
			我方经手人: 
			<input class="easyui-textbox" type="text" id="ourHandler" style="width:100px;height:25px;">
			
			交付日期：<input class="easyui-datebox"  id="deliveryDateBegin" style="width:100px;height:25px;">
			至  <input class="easyui-datebox"  id="deliveryDateEnd" style="width:100px;height:25px;">
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
		</div>
	</div>
	
	<div id="lookDetail" class="easyui-window" title="交付物详情" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:1250px; height:450px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<table width="100%" height="100%">
					<tr>
						<td width="130px" align="right">交付物名称：</td>
						<td>
							<input class="easyui-textbox" id="lookName" style="width: 150px;" readonly="readonly">
						</td>
						
						
						<td width="130px" align="right">所属产品：</td>
						<td>
							<select id = "lookProduct" class="easyui-combobox" disabled="disabled" style="width: 150px;">
								<c:forEach var="item" items="${products}" >
									<option value = "${item.id }">${item.name }</option>
								</c:forEach>
							</select>
						</td>
						
						<td width="130px" align="right">交付物类别：</td>
						<td>
							<select id = "lookProjectDeliveryTypeID" class="easyui-combobox" disabled="disabled" style="width: 150px;">
								<c:forEach var="item" items="${projectDeliveryTypes}" >
									<option value = "${item.id }">${item.name }</option>
								</c:forEach>
							</select>
						</td>
						
						<td width="130px" align="right">所属项目：</td>
						<td>
							<select id = "lookProjectID" class="easyui-combobox" disabled="disabled" style="width: 150px;">
								<c:forEach var="item" items="${projects}" >
									<option value = "${item.id }">${item.name }</option>
								</c:forEach>
							</select>
						</td>	
								
					</tr>
					
					<tr>
						<td width="130px" align="right">产品编号：</td>
						<td>
							<input class="easyui-textbox" id="lookProjectCode" style="width: 150px;" readonly="readonly">
						</td>
						
						
						<td width="130px" align="right">批次号：</td>
						<td>
							<input class="easyui-textbox" id="lookBatchNo" style="width: 150px;" readonly="readonly">
						</td>
						
						<td width="130px" align="right">生产厂家：</td>
						<td>
							<input class="easyui-textbox" id="lookProducer" style="width: 150px;" readonly="readonly">
						</td>
						
						<td width="130px" align="right">交付日期：</td>
						<td>
							<input class="easyui-datebox" id="lookDeliveryDate" style="width: 150px;" readonly="readonly">
						</td>
					</tr>
				
					<tr>
						<td width="130px" align="right">交付数量：</td>
						<td>
							<input class="easyui-textbox" id="lookDeliveryNumber" style="width: 150px;" readonly="readonly">
						</td>
						
						
						<td width="130px" align="right">单位：</td>
						<td>
							<input class="easyui-textbox" id="lookUnit" style="width: 150px;" readonly="readonly">
						</td>
						
						<td width="130px" align="right">状态：</td>
						<td>
							<input class="easyui-textbox" id="lookStatus" style="width: 150px;" readonly="readonly">
						</td>
						
						<td width="130px" align="right">凭证号码：</td>
						<td>
							<input class="easyui-textbox" id="lookVoucherNo" style="width: 150px;" readonly="readonly">
						</td>
					</tr>
					
					<tr>
						<td width="130px" align="right">录入人：</td>						
						<td>
							<select id = "lookInputPerson" class="easyui-combobox" disabled="disabled" style="width: 150px;">
								<c:forEach var="item" items="${inputPersons}" >
									<option value = "${item.id }">${item.name }</option>
								</c:forEach>
							</select>
						</td>
						
						<td width="130px" align="right">录入日期：</td>
						<td>
							<input class="easyui-datebox" id="lookInputTime" style="width: 150px;" readonly="readonly">
						</td>
						
						<td width="130px" align="right">审核人：</td>						
						<td>
							<select id = "lookCheckPerson" class="easyui-combobox" disabled="disabled" style="width: 150px;">
								<c:forEach var="item" items="${checkPersonPersons}" >
									<option value = "${item.id }">${item.name }</option>
								</c:forEach>
							</select>
						</td>
						
						<td width="130px" align="right">审核日期：</td>
						<td>
							<input class="easyui-datebox" id="lookCheckTime" style="width: 150px;" readonly="readonly">
						</td>
					</tr>
									
					<tr>
						<td width="130px" align="right">我方经手人：</td>
						<td>
							<input class="easyui-textbox" id="lookOurHandler" style="width: 150px;" readonly="readonly">
						</td>
						
						<td width="130px" align="right">对方经手人：</td>
						<td>
							<input class="easyui-textbox" id="lookCustomerHandler" style="width: 150px;" readonly="readonly">
						</td>						
						
						<td width="130px" align="right">交付方式：</td>
						<td>
							<select id = "lookDeLiveryWay" class="easyui-combobox" disabled="disabled" style="width: 150px;">
								<c:forEach var="item" items="${deliveryWays}" >
									<option value = "${item.id }">${item.name }</option>
								</c:forEach>
							</select>
						</td>
						
						<td width="130px" align="right">交付地点：</td>
						<td>
							<input class="easyui-textbox" id="lookDeliveryAddress" style="width: 150px;" readonly="readonly">
						</td>
					</tr>
					
					<tr>
					
						<td width="130px" align="right">保修期限：</td>
						<td>
							<input class="easyui-textbox" id="lookWarrantyDate" style="width: 150px;" readonly="readonly">
						</td>
						
						<td width="130px" align="right">备注：</td>
						<td>
							<input class="easyui-textbox" id="lookRemark" style="width: 150px;" readonly="readonly">
						</td>
						
					</tr>
					
					<tr>
						<td align="right">规格参数：</td>
						<td colspan="7">
							<input class="easyui-textbox" id="lookSpec" readonly="readonly" style="width: 1010px; height: 80px;" data-options="multiline:true" />
						</td>
					</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:$('#lookDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<div id="addItem" class="easyui-window" title="新增交付物" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:1250px; height:450px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<form id="form" method="post" action="editProjectDelivery" style = "width:100%; height: 100%">					
					<table width="100%" height="100%">
						<tr>
							<td width="130px" align="right">交付物名称：</td>
							<td>
								<input class="easyui-textbox" name="name" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">所属产品：</td>
							<td>
								<select data-options="editable: false" name = "product.id" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${products }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>							
							
							<td width="130px" align="right">交付物类别：</td>
							<td>
								<select data-options="editable: false" name = "projectDeliveryType.id" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${projectDeliveryTypes }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							
							<td width="130px" align="right">所属项目：</td>
							<td>
								<select data-options="editable: false" name = "project.id" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${projects }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
						</tr>
						
						<tr>
							<td  width="130px" align="right">产品编号：</td>
							<td>
								<input class="easyui-textbox" name="projectCode" style="width: 150px;" />
							</td>
							<td  width="130px" align="right">批次号：</td>
							<td>
								<input class="easyui-textbox" name="batchNo" style="width: 150px;" />
							</td>
							<td  width="130px" align="right">生产厂家：</td>
							<td>
								<input class="easyui-textbox" name="producer" style="width: 150px;" />
							</td>
							<td width="130px" align="right">交付日期：</td>
							<td>
								<input class="easyui-datebox" name="deliveryDate" style="width: 150px;"/>
							</td>
							
						</tr>
						
						<tr>
							<td width="130px" align="right">录入人：</td>
							<td>
								<select data-options="editable: false" name = "inputPerson.id" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${peoples }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
						
							<td width="130px" align="right">录入日期：</td>
							<td>
								<input class="easyui-datebox" name="inputTime" style="width: 150px;"/>
							</td>
							
							<td width="130px" align="right">审核人：</td>
							<td>
								<select data-options="editable: false" name = "checkPerson.id" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${peoples }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							
							<td width="130px" align="right">审核日期：</td>
							<td>
								<input class="easyui-datebox" name="checkTime" style="width: 150px;"/>
							</td>
						</tr>
						
						<tr>
							<td align="right">交付数量：</td>
							<td>
								<input class="easyui-textbox" name="deliveryNumber" style="width: 150px;" />
							</td>
							<td align="right">单位：</td>
							<td>
								<input class="easyui-textbox" name="unit" style="width: 150px;" />								
							</td>
							<td align="right">状态：</td>
							<td>
								<input class="easyui-textbox" name="status" style="width: 150px;" />								
							</td>
							<td align="right">凭证号码：</td>
							<td>								
								<input class="easyui-textbox" name="voucherNo" style="width: 150px;" />
							</td>
						</tr>
						
						<tr>
							<td align="right">我方经手人：</td>
							<td>
								<input class="easyui-textbox" name="ourHandler" style="width: 150px;"/>
							</td>
							<td align="right">对方经手人：</td>
							<td>
								<input class="easyui-textbox" name="customerHandler" style="width: 150px;" />
							</td>
							<td align="right">交付方式：</td>
							<td>
								<select data-options="editable: false" name = "deliveryWay.id" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${deliveryWays }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">交付地点：</td>
							<td>
								<input class="easyui-textbox" name="deliveryAddress" style="width: 150px;"/>
							</td>
						</tr>
						
						<tr>
							<td align="right">保修期限：</td>
							<td>
								<input class="easyui-textbox" name="warrantyDate" style="width: 150px;"/>
							</td>
							<td align="right">备注：</td>
							<td>
								<input class="easyui-textbox" name="remark" style="width: 150px;"/>
							</td>
						</tr>
						
						<tr>
							<td align="right">规格参数：</td>
							<td colspan="7">
								<input class="easyui-textbox" name="spec" style="width: 1010px; height: 80px;" data-options="multiline:true" />
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="$('#form').submit()" style="width:80px">确 定</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#addItem').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<div id="editItem" class="easyui-window" title="编辑" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:1250px; height:450px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<form id="editForm" method="post" action="editProjectDelivery" style = "width:100%; height: 100%">
					<input type="hidden" id="editId" name = "id">					
					<table width="100%" height="100%">
						<tr>
							<td width="130px" align="right">交付物名称：</td>
							<td>
								<input class="easyui-textbox" name="name" id="editName" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">所属产品:</td>
							<td>
								<select data-options="editable: false" name = "product.id" id="editProductId" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${products }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							
							<td width="130px" align="right">交付物类别：</td>
							<td>
								<select data-options="editable: false" name = "projectDeliveryType.id" id="editProjectDeliveryTypeId" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${projectDeliveryTypes }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							
							<td width="130px" align="right">所属项目：</td>
							<td>
								<select data-options="editable: false" name = "project.id" id="editProjectId" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${projects }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
						</tr>
						
						<tr>
							<td width="130px" align="right">产品编号：</td>
							<td>
								<input class="easyui-textbox" name="projectCode" id="editProjectCode" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">批次号：</td>
							<td>
								<input class="easyui-textbox" name="batchNo" id="editBatchNo" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">生产厂家：</td>
							<td>
								<input class="easyui-textbox" name="producer" id="editProducer" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">交付日期： </td>
							<td>
								<input class="easyui-datebox" name="deliveryDate" id="editDeliveryDate" style="width: 150px;"/>
							</td>
							
						</tr>
						
						<tr>
							
							<td width="130px" align="right">录入人：</td>
							<td>
								<select data-options="editable: false" name = "inputPerson.id" id="editInputPerson" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${peoples }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>							
							
							
							<td align="right">录入日期：</td>
							<td>
								<input class="easyui-datebox" name="inputTime" id="editInputTime" style="width: 150px;"/>
							</td>
													
							<td width="130px" align="right">审核人：</td>							
							<td>
								<select data-options="editable: false" name = "checkPerson.id" id="editCheckPerson" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${peoples }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							
							<td align="right">审核日期：</td>
							<td>
								<input class="easyui-datebox" name="checkTime" id="editCheckTime" style="width: 150px;"/>
							</td>
						
						</tr>
						
						<tr>
							<td width="130px" align="right">交付数量：</td>
							<td>
								<input class="easyui-textbox" name="deliveryNumber" id="editDeliveryNumber" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">单位：</td>
							<td>
								<input class="easyui-textbox" name="unit" id="editUnit" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">状态：</td>
							<td>
								<input class="easyui-textbox" name="status" id="editStatus" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">凭证号码：</td>
							<td>
								<input class="easyui-textbox" name="voucherNo" id="editVoucherNo" data-options="required:true" style="width: 150px;" />
							</td>
						</tr>	
						
						<tr>
							<td width="130px" align="right">我方经手人：</td>
							<td>
								<input class="easyui-textbox" name="ourHandler" id="editOurHandler" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">对方经手人：</td>
							<td>
								<input class="easyui-textbox" name="customerHandler" id="editCustomerHandler" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">交付方式：</td>
							<td>
								<select data-options="editable: false" name = "deliveryWay.id" id="editDeliveryWayId" class="easyui-combobox" style="width: 150px;">
									<c:forEach var="item" items="${deliveryWays }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px" align="right">交付地点：</td>
							<td>
								<input class="easyui-textbox" name="deliveryAddress" id="editDeliveryAddress" data-options="required:true" style="width: 150px;" />
							</td>
							
						</tr>
						
						<tr>
							<td width="130px" align="right">保修期限：</td>
							<td>
								<input class="easyui-textbox" name="warrantyDate" id="editWarrantyDate" data-options="required:true" style="width: 150px;" />
							</td>
							
							<td width="130px" align="right">备注：</td>
							<td>
								<input class="easyui-textbox" name="remark" id="editRemark" data-options="required:true" style="width: 150px;" />
							</td>
						</tr>
						
						<tr>
							<td align="right">规格参数：</td>
							<td colspan="7">
								<input class="easyui-textbox" name="spec" id="editSpec" style="width: 1010px; height: 80px;" data-options="multiline:true" />
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="$('#editForm').submit()" style="width:80px">确 定</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#editItem').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		function formatControl(val, row){
			return '<a class="ctl" href="javascript:void(0)" onclick="lookDetail(' + val + ')">查看</a>'+
			' <a class="ctl" href="javascript:void(0)" onclick="editItem(' + val + ')">编辑</a>'+
			' <a class="ctl" href="javascript:void(0)" onclick="delItem(' + val + ')">删除</a>';
		}
		function search(){
			var dg = $("#dg");
			var name = $("#name").textbox("getValue").trim();
			var project = $("#project").textbox("getValue").trim();
			var batchNo = $("#batchNo").textbox("getValue").trim();
			var ourHandler = $("#ourHandler").textbox("getValue").trim();
			var deliveryDateBegin = $("#deliveryDateBegin").textbox("getValue").trim();
			var deliveryDateEnd = $("#deliveryDateEnd").textbox("getValue").trim();
			var url = "queryProjectDelivery?projectId=" + project + "&batchNo=" + batchNo + "&ourHandler=" + ourHandler + "&deliveryDateBegin=" + deliveryDateBegin + "&deliveryDateEnd=" + deliveryDateEnd + "&name=" + name;
			dg.datagrid('reload', url);
		}
		function lookDetail(id){
			var params = "id=" + id;
			$.ajax({
				  type: "GET",
				  url: "findProjectDelivery",
				  data: params,
				  success:function(data){
					  	var val = $.parseJSON(data);
						if(val.success){
							var item = val.data;

							$("#lookProjectID").combobox("setValue", item.projectID);
							$("#lookProductID").combobox("setValue", item.productID);
							$("#lookDeliveryWayID").combobox("setValue", item.deliveryWayID);
							$("#lookProjectDeliveryTypeID").combobox("setValue", item.projectDeliveryTypeID);
							
							$("#lookInputPerson").textbox("setValue", item.inputPerson);
							$("#lookCheckPerson").textbox("setValue", item.checkPerson);
							$("#lookProducer").textbox("setValue", item.producer);
							$("#lookProjectCode").textbox("setValue", item.projectCode);
							$("#lookName").textbox("setValue", item.name);
							$("#lookBatchNo").textbox("setValue", item.batchNo);
							$("#lookSpec").textbox("setValue", item.spec);
							$("#lookUnit").textbox("setValue", item.unit);
							$("#lookDeliveryNumber").textbox("setValue", item.deliveryNumber);
							$("#lookDeliveryDate").textbox("setValue", item.deliveryDate);
							$("#lookOurHandler").textbox("setValue", item.ourHandler);
							$("#lookCustomerHandler").textbox("setValue", item.customerHandler);
							$("#lookDeliveryAddress").textbox("setValue", item.deliveryAddress);
							$("#lookVoucherNo").textbox("setValue", item.voucherNo);
							$("#lookRemark").textbox("setValue", item.remark);
							$("#lookInputTime").textbox("setValue", item.inputTime);
							$("#lookCheckTime").textbox("setValue", item.checkTime);
							$("#lookStatus").textbox("setValue", item.status);
							$("#lookWarrantyDate").textbox("setValue", item.warrantyDate);
							
							$('#lookDetail').window('open');
						}else{
							$.messager.alert("提示", val.msg, "error");
						}
				  }
			});
		}
		function editItem(id){
			var params = "id=" + id;
			$.ajax({
				  type: "GET",
				  url: "findProjectDelivery",
				  data: params,
				  success:function(data){
					  	var val = $.parseJSON(data);
						if(val.success){
							var item = val.data;

							$("#editId").val(id);
							$("#editProjectID").combobox("setValue", item.projectID);
							$("#editProductID").combobox("setValue", item.productID);
							$("#editDeliveryWayID").combobox("setValue", item.deliveryWayID);
							$("#editProjectDeliveryTypeID").combobox("setValue", item.projectDeliveryTypeID);
							
							$("#editInputPerson").textbox("setValue", item.inputPerson);
							$("#editCheckPerson").textbox("setValue", item.checkPerson);
							$("#editProducer").textbox("setValue", item.producer);
							$("#editProjectCode").textbox("setValue", item.projectCode);
							$("#editName").textbox("setValue", item.name);
							$("#editBatchNo").textbox("setValue", item.batchNo);
							$("#editSpec").textbox("setValue", item.spec);
							$("#editUnit").textbox("setValue", item.unit);
							$("#editDeliveryNumber").textbox("setValue", item.deliveryNumber);
							$("#editDeliveryDate").textbox("setValue", item.deliveryDate);
							$("#editOurHandler").textbox("setValue", item.ourHandler);
							$("#editCustomerHandler").textbox("setValue", item.customerHandler);
							$("#editDeliveryAddress").textbox("setValue", item.deliveryAddress);
							$("#editVoucherNo").textbox("setValue", item.voucherNo);
							$("#editRemark").textbox("setValue", item.remark);
							$("#editInputTime").textbox("setValue", item.inputTime);
							$("#editCheckTime").textbox("setValue", item.checkTime);
							$("#editStatus").textbox("setValue", item.status);
							$("#editWarrantyDate").textbox("setValue", item.warrantyDate);
							
							$('#editItem').window('open');
						}else{
							$.messager.alert("提示", val.msg, "error");
						}
				  }
			});
		}
		function delItem(id){
			$.messager.confirm("删除确认", "您确定要删除所选的项目吗？", function(r){
				if(r){
					params = "id=" + id;
					$.ajax({
					  type: "GET",
					  url: "delProjectDelivery",
					  data: params,
					  success:function(data){
						var val = $.parseJSON(data);
						if(val.success){
							bottomRight('提示', '操作成功！');
							$('#dg').datagrid('reload');
						}else{
							$.messager.alert("提示", val.msg, "error");
						}
					  }
					});
				}
			});
		}
		$(function(){
			$("#form").form({
				onSubmit: function(){
					var isValid = $(this).form('validate');
					return isValid;	// 返回false将停止form提交 
			    },
				success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						$('#dg').datagrid('reload');
						bottomRight('提示', '操作成功！');
						$('#addItem').window('close');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
				}
			});
			$("#editForm").form({
				onSubmit: function(){
					var isValid = $(this).form('validate');
					return isValid;	// 返回false将停止form提交 
			    },
				success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						$('#dg').datagrid('reload');
						bottomRight('提示', '操作成功！');
						$('#editItem').window('close');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
				}
			});
			search();
		});
	</script>
</body>
</html>